﻿using System;
using UnityEngine;
/// <summary>
/// 文件后续属性
/// </summary>
[AttributeUsage(AttributeTargets.Field, Inherited = true, AllowMultiple = false)]
public class ESF_FileExtAttribute : PropertyAttribute
{
    /// <summary>
    /// 构造函数
    /// </summary>
    /// <param name="_ext">后缀</param>
    public ESF_FileExtAttribute(string _ext)
    {
        ext = _ext;
        noDotExt = _ext.Replace(".", "");
        searchPattern = "*" + _ext;
    }
    /// <summary>
    /// 扩展名
    /// </summary>
    public string ext { get; private set; }
    /// <summary>
    /// 不带点扩展名
    /// </summary>
    public string noDotExt { get; private set; }
    /// <summary>
    /// 搜索规则
    /// </summary>
    public string searchPattern { get; private set; }
    /// <summary>
    /// 是否是指定的后缀
    /// </summary>
    /// <param name="_ext">指定的后缀</param>
    /// <returns>true:是,false:否</returns>
    public bool IsExt(string _ext)
    {
        return !string.IsNullOrEmpty(_ext) && ext.ToUpper().Equals(_ext.ToUpper());
    }
}